package utils;

/**
 * 控制台颜色控制
 * @author or2
 * @see <a href="https://en.wikipedia.org/wiki/ANSI_escape_code#Colors">维基百科 ANSI编码</a>
 */
public class IPrint {

    public static final String WRITE_RED_BOLD_UNDERRLINE = "[107;38;5;88;1;4;6m";
    public static final String BLURE_AND_GREEN = "[38;5;86;1;6m";
    public static final String ERROR = "[38;5;196;1;6m";
    public static final String CLEAR = "[0m";

    public static void printWithColor(String msg) {
        System.out.println(WRITE_RED_BOLD_UNDERRLINE + msg + CLEAR);
    }

    /**
     * 等价于 <=> {@code System.out.printf(String fommat, Object ... args)} 函数
     * @param fommat 按 <a href="../util/Formatter.html#syntax">Format string syntax</a> 撰写的格式化字符串
     * @param args 替换参数
     */
    public static void printWithColor(String fommat, Object ... args) {
        String msg = String.format(fommat, args);
        System.out.println(WRITE_RED_BOLD_UNDERRLINE + msg + CLEAR);
    }

    public static void printWithColorNoBg(String msg) {
        System.out.println(BLURE_AND_GREEN + msg + CLEAR);
    }

    public static void printError(String msg) {
        System.out.println(ERROR + msg + CLEAR);
    }
}
